package array01;

import java.util.ArrayList;
import java.util.List;

public class MonsterTest {
    public static void main(String[] args) {
        List<Monster> 怪兽兵团 = new ArrayList<>();

        怪兽兵团.add(new Vampire("number 1"));
        怪兽兵团.add(new Vampire("1 number"));
        怪兽兵团.add(new Dragon("dragen"));

        for (Monster monster : 怪兽兵团) {
            System.out.print(monster);
            monster.highSpeedMove();
            monster.frighten();
            if (monster.eatHuman()) {
                System.out.println("kill monster!!!" + monster);
            } else {
                System.out.println("happy monster!!!" + monster);

            }
        }
    }

}

abstract class Monster {
    private String name;

    public Monster(String name) {
        this.name = name;
    }

    abstract void highSpeedMove();

    boolean eatHuman() {
        return true;
    }

    abstract void frighten();

    @Override
    public String toString() {
        return "Monster{" +
                "name='" + name + '\'' +
                '}';
    }
}

class Vampire extends Monster {

    public Vampire(String name) {
        super(name);
    }

    @Override
    void highSpeedMove() {
        System.out.println("fly 200km/min");
    }

    @Override
    boolean eatHuman() {
        return false;
    }

    @Override
    void frighten() {
        System.out.println("a bite?");
    }

}

class Dragon extends Monster {
    public Dragon(String name) {
        super(name);
    }

    @Override
    void highSpeedMove() {
        System.out.println("run 20Km/h");
    }

    @Override
    void frighten() {
        System.out.println("breath fire");

    }
}